library SelectFRCommand initializer init requires LegacySystem, PlayerSelectsHeroCommand, LegacyHumanAbilities

	private function Trig_Player_Selects_Recon_Conditions takes nothing returns boolean
		if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'H006' ) ) then
			return false
		endif
		return true
	endfunction


	private function Trig_Player_Selects_Recon_Actions takes nothing returns nothing

		local unit u = GetTriggerUnit()
		local player p = GetOwningPlayer(u)
		local integer id = GetConvertedPlayerId(p)

		call putUnit(p,"hero", u)

		call setPlayerDataInteger(p,"pistol_ammo",8)
		call setPlayerDataInteger(p,"pistol_type",0)
		call setPlayerDataBoolean(p,"pistol_reload",false)

		call SetUnitUserData(u,50)

		set udg_HeroAvailable[8] = 0
	   
		call putUnit(null,"ReconUnit", u)    
	   
		set udg_PlayerIcon[id] = "ReplaceableTextures\\CommandButtons\\BTN_Unit_Recon.blp"
		set udg_KillFactor[id] = 1.3
		call SetPlayerHandicap(Player(13),GetPlayerHandicap(Player(13))-0.02)
		call SetPlayerHandicap(Player(14),GetPlayerHandicap(Player(14))-0.02)
		call FogMaskEnableOff()

		set udg_ReloadTime[id] = 4.0
		
		call AddPrimaryAmmo(u, 15, 50)
		call RegisterAmmoAutoReloadListener(u)
		call RegisterAmmoEmptyListener(u)
		
		//if udg_Mode!=3 then
		//	call TriggerRegisterPlayerUnitEventSimple( gg_trg_Chemlights, p, EVENT_PLAYER_UNIT_SPELL_CAST )
		//endif

		call InitHero(u)
		
		if GetI("player mos", id) == 7 then
			call ModifyHeroSkillPoints( u, bj_MODIFYMETHOD_ADD, 1 )
		endif
		
		
		set u = null
		set p = null
		
		if( udg_HeroAvailable[8] <= 0 ) then
			call DisableTrigger(GetTriggeringTrigger())
		endif
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger(  )
		call TriggerRegisterEnterRectSimple( t, GetPlayableMapRect() )
		call TriggerAddCondition( t, Condition( function Trig_Player_Selects_Recon_Conditions ) )
		call TriggerAddAction( t, function Trig_Player_Selects_Recon_Actions )
	endfunction


endlibrary